package com.ct.code.tools.util;

import java.util.HashMap;
import java.util.Map;

public class TypeMap {
	
	public static final String db_type_oracle = "Oracle";
	public static final String db_type_mysql = "mysql";
	
	
	public static Map<String,Map<String,String>> typeMapping = new HashMap<String,Map<String,String>>();
	
	private static Map<String,String> mySqlMap = new HashMap<String,String>();
	private static Map<String,String> oracleMap = new HashMap<String,String>();
	private static Map<String,String> javaType2jdbcTypeMap = new HashMap<String,String>();
	
	static{
		mySqlMap.put("BIGINT", "Long");
		mySqlMap.put("VARCHAR", "String");
		mySqlMap.put("TEXT", "String");
		mySqlMap.put("SMALLINT", "Integer");
		mySqlMap.put("INT", "Integer");
		mySqlMap.put("DATETIME", "Timestamp");
		mySqlMap.put("DECIMAL", "BigDecimal");
		
		javaType2jdbcTypeMap.put("Timestamp", "TIMESTAMP");
		javaType2jdbcTypeMap.put("BigDecimal", "DECIMAL");
		javaType2jdbcTypeMap.put("Integer", "INTEGER");
		javaType2jdbcTypeMap.put("String", "VARCHAR");
		javaType2jdbcTypeMap.put("Long", "BIGINT");
		
		
		oracleMap.put("VARCHAR2", "String");
		oracleMap.put("CHAR", "String");
		oracleMap.put("CLOB", "String");
		oracleMap.put("DATE", "String");
		oracleMap.put("NUMBER", "String");
		
		typeMapping.put(db_type_mysql, mySqlMap);
		typeMapping.put(db_type_oracle, oracleMap);
	}
	
	public static String getJavaType(String dbType,String columnType)
	{
		return typeMapping.get(dbType).get(columnType);
		
	}
	
	public static String javaType2jdbcType(String javaType)
	{
		return javaType2jdbcTypeMap.get(javaType);
		
	}
	

}
